import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  // 添加全局验证
  app.useGlobalPipes(new ValidationPipe({ transform: true }));
  app.enableCors(); // 支持跨域

  app.useStaticAssets(join(__dirname, '..', 'uploads'), {
    prefix: '/uploads',
  });
  // app.useStaticAssets(join(__dirname, '..', 'public'), {
  //   prefix: '/public',
  // });

  await app.listen(process.env.PORT ?? 3001);
}
bootstrap();
